<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="system" tagdir="/WEB-INF/tags/system"%>
<%@ taglib prefix="sales" tagdir="/WEB-INF/tags/sales"%>
<title>结账</title>
		<div class="shopping_step">
			<ul>
				<li class="s1"><span><a href="${ctxPath}/cart/shoppingcart.html">1.<fmt:message key="checkout.process.step1" /></a></span></li>
				<li class="s2"><span class="curr">2.<fmt:message key="checkout.process.step2" /></span></li>
				<li class="s3"><span>3.<fmt:message key="checkout.process.step3" /></span></li>
			</ul>
		</div>
		<sales:exceptionMsg msgContent="${exceptionMsg }"></sales:exceptionMsg>
		<div class="checkout">
			<div class="top"><span><fmt:message key="checkout.fillup"/></span></div>
			<div class="content">
				<div class="order_info">
					<!-- 收货人信息面板 -->
					<c:choose>
						<c:when test="${checkoutSession.shippingRequired}">
							<%@include file="include/onePageCheckoutConsignee.jspf"%>
						</c:when>
						<c:otherwise>
							<%@include file="include/onePageCheckoutVirtualConsignee.jspf"%>
						</c:otherwise>
					</c:choose>
					
					<!-- 支付及配送方式信息面板 -->
					<%@include file="include/onePageCheckoutPaymentMethod.jspf"%>
					
					<!-- 发票信息面板 -->
					<c:if test="${checkoutSession.invoiceEnabled}">
						<%@include file="include/onePageCheckoutInvoice.jspf"%>
					</c:if>
					
					<!-- 备注信息面板 -->
					<%@include file="include/onePageCheckoutRemark.jspf"%>
					
					<!-- 包装信息面板 start -->
					<c:if test="${checkoutSession.giftWrapEnabled}">
						<%@include file="include/onePageCheckoutGiftWrap.jspf"%>
					</c:if>
					
					<div class="o_cart">
						<h3><fmt:message key="checkout.productList"/></h3>
						<div class="middle clearfix">
							<table border="0" cellspacing="0" cellpadding="0" class="t5">
								<tr>
									<th width="15%"><fmt:message key="checkout.productSkuCode"/></th>
									<th width="60%"><fmt:message key="checkout.productName"/></th>
									<th width="15%"><fmt:message key="checkout.productPrice"/></th>
									<th width="10%"><fmt:message key="checkout.productQuantity"/></th>
								</tr>
								<c:forEach items="${shoppingcart.productItems}" var="item" varStatus="status">
								<tr>
									<td>${item.productSku.productSkuCode}</td>
									<td>
										<a href="<product:productUrl product="${item.productSku.product}"/>" target="_blank">${item.productSku.product.productName}</a>
										<span>${item.productSku.orderSkuDisplayOption}</span>
									</td>
									<td><span class="red"><common:currencyFormat value="${item.discountPrice}"/></span></td>
									<td>${item.quantity}</td>
								</tr>
								</c:forEach>
								<c:forEach items="${shoppingcart.giftCertificateItems}" var="item" varStatus="status">
								<tr>
									<td>N/A</td>
									<td>
										<fmt:message key="shoppingcart.gcName"/>
										<span style="color:#A0A0A4; font-size:11px ">
											<span><fmt:message key="giftCertificate.giftCertAmt"/>:<common:currencyFormat value="${item.discountPrice}"/></span>
											<c:if test="${not empty item.shoppingcartItemGc.recipient}">
												<span><fmt:message key="shoppingcart.gcRecipient"/>:${item.shoppingcartItemGc.recipient}</span>
											</c:if>
											<span><fmt:message key="shoppingcart.gcRecipientEmail"/>:${item.shoppingcartItemGc.recipientEmail}</span>
										</span>
									</td>
									<td><span class="red"><common:currencyFormat value="${item.discountPrice}"/></span></td>
									<td>${item.quantity}</td>
								</tr>
								</c:forEach>
							</table>
							<c:if test="${checkoutSession.promotionApplied}">
								<div class="o_account" >
									<div class="content">
										<div>
											<div class="ticket">
												<div>
												<fmt:message key="checkout.discountopion"/>：
												<c:forEach var="promotion" items="${shoppingcart.shoppingCartPromotions}">
													<a href="<sales:promoRuleUrl promoRuleId="${promotion.promoRuleId}"/>" target="_blank" title="${promotion.promotionName}">${promotion.promotionName}</a>&nbsp;&nbsp;&nbsp;&nbsp;
												</c:forEach>
												<c:if test="${not empty coupone}">
													<h6><fmt:message key="checkout.gainCoupon" />：${coupone.name}</h6>
												</c:if>
												<c:if test="${shoppingcart.gainedPoint!=0}">
													<h6><fmt:message key="checkout.gainPoint" />：${shoppingcart.gainedPoint}</h6>
												</c:if>
												<c:if test="${not empty shoppingcart.promoGiftList}">
													<h6><fmt:message key="checkout.gainGift" />：</h6>
													<table class="t1" style="width:100%">
														<tr>
															<th><fmt:message key="productSku.promotion.gift.name" /></th>
															<th style="width:80px"><fmt:message key="productSku.promotion.gift.num" /></th>
														</tr>
														<c:forEach var="promoGift" items="${shoppingcart.promoGiftList}">
														<tr>
															<td>
																${promoGift.giftName}
															</td>
															<td>${promoGift.orderSkuQuantity}${promoGift.weightMeasureUnitName}</td>
														</tr>
														</c:forEach>
													</table>
												</c:if>
												</div>
											</div>
										</div>
									</div>
								</div>
							</c:if>
							<div class="o_account" id="billInfoPanel">
								<h4><fmt:message key="checkout.bill"/></h4>
								<div class="content">
									<table border="0" cellspacing="0" cellpadding="0" class="t6">
										<tr>
											<td>
												<fmt:message key="checkout.bill.productTotal"/>：<span id="productTotalLabel"></span> 
												<c:if test="${checkoutSession.giftWrapEnabled}">
												+ <fmt:message key="checkout.bill.giftWrapCost"/>：<span id="giftWrapCostLabel"></span>
												</c:if>
												+ <fmt:message key="checkout.bill.shippingCost"/>：<span id="shippingCostLabel"></span>
												<c:if test="${checkoutSession.taxEnabled}">
												+ <fmt:message key="checkout.bill.tax"/>：<span id="taxLabel"></span>
												</c:if> 
												- <fmt:message key="checkout.bill.discount"/>：<span id="discountLabel"></span>
												<c:if test="${checkoutSession.giftCertificatePaymentEnabled}"> 
												- <fmt:message key="checkout.bill.giftCertificatePaidTotal"/>：<span id="giftCertificatePaidTotalLabel"></span>
												</c:if> 
												<c:if test="${checkoutSession.shopPointPaymentEnabled}">
												- <fmt:message key="checkout.bill.shopPointPaidTotal"/>：<span id="shopPointPaidTotalLabel"></span>
												</c:if>
											</td>
											<td align="right" class="value_s"><fmt:message key="checkout.bill.total"/>：<span id="totalLabel" class="total"></span></td>
										</tr>
									</table>
									
									<!-- 礼品券支付 -->
									<c:if test="${checkoutSession.giftCertificatePaymentEnabled}">
									<%@include file="include/onePageCheckoutGiftCertificatePayment.jspf"%>
									</c:if>

									<!-- 积分支付 -->
									<c:if test="${checkoutSession.shopPointPaymentEnabled}">
									<%@include file="include/onePageCheckoutShopPointPayment.jspf"%>
									</c:if>

								</div>
							</div>
						</div>
					</div>
					<!-- <div class="o_cart">
						<h3>TODO: 积分兑换礼品</h3>
						<div class="middle">
							<table border="0" cellspacing="0" cellpadding="0" class="t5">
								<tr>
									<th width="15%">商品编号</th>
									<th width="50%">商品名称</th>
									<th width="15%">商城价</th>
									<th width="10%">积分</th>
									<th width="10%">商品数量</th>
								</tr>
								<tr>
									<td>157636</td>
									<td><a href="#">皇家遗韵 O.SA欧莎09冬束腰双排扣女呢大衣/呢子大衣/外套SD81002 </a></td>
									<td><span class="red">￥869.00</span></td>
									<td><span class="red">80分</span></td>
									<td>1</td>
								</tr>
								<tr>
									<td>158952</td>
									<td><a href="#">TCL洗衣机 XQB50-32S</a> </td>
									<td><span class="red">￥1488.00</span></td>
									<td><span class="red">140分</span></td>
									<td>1</td>
								</tr>
							</table>
							<div class="point">积分总数：<span class="big">220</span>分</div>
						</div>
					</div>
				  -->
				</div>
				<div class="order_go">
					<a href="${ctxPath}/cart/shoppingcart.html"><fmt:message key="checkout.goToCart"/></a>
					<input id="btnPlaceOrder" type="image" src="${txtImagePath}/btn_submit_order.gif" onclick="return controller.placeOrder(this)" alt="<fmt:message key="checkout.placeOrder" />" />
				</div>
			</div>
		</div>

<c:set var="probizJs_dwr_util" value="true" scope="request"/>	
<c:set var="probizJs_regionLinkage" value="true" scope="request"/>	
<script type="text/javascript">
var controller;
$j(document).ready(function () {
	$j("#minicartDiv").remove();						//禁止迷你购物车弹出
	controller = new OnePageCheckoutController();

	<c:choose>
		<c:when test="${not checkoutSession.shippingRequired}">
			controller.disableModule("consignee");			//屏蔽真实收货人信息区
			<c:choose>
				<c:when test="${checkoutSession.firstTimeCheckout}">
					controller.edit("virtualConsignee");		//设置虚拟收货人区域初始视图为编辑
				</c:when>
				<c:otherwise>
					controller.showInfo("virtualConsignee");	//设置虚拟收货人区域初始视图为显示
				</c:otherwise>
			</c:choose>
		</c:when>
		<c:otherwise>
			controller.disableModule("virtualConsignee");	//屏蔽虚拟收货人信息区
			<c:choose>
				<c:when test="${checkoutSession.consigneeInfoEmpty}">
					controller.edit("consignee");				//设置真实收货人区域初始视图为编辑
				</c:when>
				<c:otherwise>
					controller.showInfo("consignee");			//设置真实收货人区域初始视图为显示
				</c:otherwise>
			</c:choose>
		</c:otherwise>
	</c:choose>
	
	<c:choose>
		<c:when test="${not checkoutSession.invoiceEnabled}">
			controller.disableModule("invoice");			//屏蔽发票区
		</c:when>
		<c:otherwise>
			controller.showInfo("invoice");					//设置发票区域初始视图为显示
		</c:otherwise>
	</c:choose>
	
	<c:choose>
		<c:when test="${not checkoutSession.giftWrapEnabled}">
			controller.disableModule("giftWrap");			//屏蔽包装区
		</c:when>
		<c:otherwise>
			controller.showInfo("giftWrap");				//设置包装区为显示
		</c:otherwise>
	</c:choose>
	
	<c:if test="${not checkoutSession.giftCertificatePaymentEnabled}">
		controller.disableModule("giftCertificatePayment");		//屏蔽礼券支付区
	</c:if>
	
	<c:if test="${not checkoutSession.shopPointPaymentEnabled}">
		controller.disableModule("shopPointPayment");	//屏蔽积分支付区
	</c:if>
	
	<c:choose>
		<c:when test="${not checkoutSession.firstTimeCheckout}">
			//如果不是第一次结账
			<c:choose>
				<c:when test="${(checkoutSession.selfCollect) and (not checkoutSession.selfCollectionCentreEmpty)}">
					//如果上一次订单选择了上门自提方式，则设置支付方式区域初始视图为显示
					$j("[group*='selfCollect']").show();
					controller.showInfo("paymentMethod");
				</c:when>
				<c:when test="${(checkoutSession.shippingRequired) and (not checkoutSession.shippingMethodEmpty)}">
					//如果上一次订单选择了支付和配送方式，则设置支付方式区域初始视图为显示
					$j("[group*='shippingMethod']").show();
					controller.showInfo("paymentMethod");
				</c:when>
				<c:when test="${(not checkoutSession.shippingRequired) and (not empty checkoutSession.paymentMethodId)}">
					//如果上次购买的全是虚拟商品、并且支付方式已经预设好，则设置支付方式区域初始视图为显示
					controller.showInfo("paymentMethod");
				</c:when>
				<c:otherwise>
					//其他情况则设置支付方式区域初始视图为编辑
					controller.edit("paymentMethod");
				</c:otherwise>
			</c:choose>
		</c:when>
		<c:otherwise>
		</c:otherwise>
	</c:choose>
	
	controller.showInfo("bill");	//设置支帐单区域初始视图为信息显示
	
	var fs = document.forms;
	for(var a=0;a<fs.length;a++){
		autoApplyValidate(fs[a]);
	}
	
});	
</script>
</body>
</html>
